package com.zhitong.money.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Author: Andy Zhang
 * @Description:
 * @Date: 14:35 2021/3/9
 * @Company: wisecard
 */
@Mapper
public interface RoleMenuMapper {

    @Insert("insert into role_menu values(#{rid},#{mid})")
    public void add(String rid,String mid);

    @Delete("delete from role_menu where rid = #{rid}")
    public void delByRid(String rid);

    @Delete({
            "<script>",
            "delete from role_menu",
            "where rid in",
            "<foreach item='item' collection='rids' open='(' close=')' separator=','>",
            "#{item}",
            "</foreach>",
            "</script>"
    })
    public void delByRids(List<String> rids);

    @Delete("delete from role_menu where mid = #{mid}")
    public void delByMid(String mid);

    @Delete({
            "<script>",
            "delete from role_menu",
            "where mid in",
            "<foreach item='item' collection='mids' open='(' close=')' separator=','>",
            "#{item}",
            "</foreach>",
            "</script>"
    })
    public void delByMids(List<String> mids);

    @Select("select count(*) from role_menu where mid = #{mid}")
    public int countByMid(String mid);

    @Select({
            "<script>",
            "select count(*) from role_menu",
            "where mid in",
            "<foreach item='item' collection='mids' open='(' close=')' separator=','>",
            "#{item}",
            "</foreach>",
            "</script>"
    })
    public int countByMids(List<String> mids);
}
